package com.ruoyi.web.controller.tzzl;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.tzzl.domain.WzCertification;
import com.ruoyi.tzzl.domain.vo.QueryVo;
import com.ruoyi.tzzl.service.IWzCertificationService;
import com.sun.org.apache.bcel.internal.generic.NEW;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 用户认证Controller
 * @author by caoyong
 * @date 2022/11/17
 **/
@RestController
@RequestMapping("/tzzl/certification")
public class WzCertificationController extends BaseController {

    @Autowired
    private IWzCertificationService wzCertificationService;

    /**
     * 查询用户认证列表
     */
    @GetMapping("/list")
    public TableDataInfo list(QueryVo queryVo)
    {
        startPage();
        List<WzCertification> list = wzCertificationService.selectWzCertificationList(queryVo);
        return getDataTable(list);
    }

    /**
     * 认证审核
     * */
    @PostMapping("audit")
    public AjaxResult audit(@RequestBody QueryVo  queryVo){
       WzCertification wzCertification = wzCertificationService.getById(queryVo.getId());
        wzCertification.setCertificationState(queryVo.getCertificationState());
        return AjaxResult.success(wzCertificationService.updateById(wzCertification));
    }

    /**提交认证申请*/
    @PostMapping("/add")
    public AjaxResult add(@RequestBody QueryVo queryVo){
        WzCertification wzCertification =new WzCertification();
        BeanUtils.copyProperties(queryVo,wzCertification);
        wzCertification.setCreateTime(new Date());
        return AjaxResult.success(wzCertificationService.save(wzCertification));
    }

    /**
     * 删除认证列表
     * */
    @DeleteMapping("/delete/{ids}")
    public AjaxResult delete(@PathVariable List<Long> ids){
        return AjaxResult.success(wzCertificationService.removeByIds(ids));
    }





}
